package space.enemy;

import org.anddev.andengine.entity.scene.Scene;

import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.region.TextureRegion;


public class Brick extends Sprite{
	public static final int DAMAGE = 20;
	public static final int LOW_HEALTH = DAMAGE;
	private int pLife;
	private boolean mAlive;
	
	public Brick(final float pX, final float pY, final TextureRegion pTextureRegion, final int pLife, final Scene pScene){
		super(pX, pY, pTextureRegion);		        	         	 
	   	pScene.getLastChild().attachChild(this);
	   	this.pLife = pLife;
	   	mAlive = true;
	}
	
	 public void decreaseLife(int pAmount) {
		pLife -= pAmount;
		if (pLife == SpaceEnemy.LOW_HEALTH) {
			
			this.setColor(1.0f, 0, 0, this.getAlpha());
		}
		else if (pLife <= 0) {
			mAlive = false;
		}
	 }
	 public boolean isAlive() {
	    	return mAlive;
	 }    
}
